# -*- coding: utf-8 -*-
# @Author  : 廖善武
# @Email   : liaosw18878@hundsum.com
# @Time    : 2018/5/15 15:29
# @File    : GetXmlData.py
import collections
from xml.dom.minidom import parse
from Lib.Common import xmlPath

def prepareDate(xmlPath):
    global InputData
    global UIExcept
    InputData = collections.OrderedDict()
    if 'UIExcept' not in dir():
        UIExcept = collections.OrderedDict()
    DOMTree = parse(xmlPath)
    collection = DOMTree.documentElement
    # if collection.hasAttribute('note'):
    #     print('执行案例' + collection.getAttribute('note'))
    subs = collection.getElementsByTagName('sub')
    num = 1
    sub = subs[0]
    # print('执行sub{{0}}:{1}'.format(num, sub.getAttribute('id')))
    num += 1
    ins = sub.getElementsByTagName('inparams')[0].getElementsByTagName('in')
    uis = sub.getElementsByTagName('UIexcept')[0].getElementsByTagName('in')
    for i in ins:
        InputData[i.getAttribute('name')] = i.getAttribute('value')
    for j in uis:
        UIExcept[j.getAttribute('name')] = j.getAttribute('value')

if __name__ == "__main__":
    prepareDate(xmlPath)
    print(InputData)
    print(UIExcept)
